<?php
/**
 * Created by PhpStorm.
 * User: wangjiangtao
 * Date: 2022/5/25
 * Time: 15:43
 */

namespace App\Model;


use Illuminate\Http\Request;
use Illuminate\Support\Facades\DB;

class BlackList extends BaseModel
{
    protected $table = 'gift_label';
    public $timestamps = false;
    private $fields = ['*'];

    public function getList(Request $request){
        $limit = $request->input('limit', 10);
        $page = $request->input('page', 1);
        $uuid = $request->input('uuid');
        $userId = $request->input('userId');
        
        $query = new self();
        $query = $query->where('status', 1);
        if(!empty($uuid)) {
            $query = $query->where('uuid', $uuid);
        }
        if(!empty($userId)) {
            $query = $query->where('user_id', $userId);
        }

        return $query->orderBy('id','desc')->paginate($limit, ['*'], 'page', $page);
    }

    public function blackListDelete($param){
        $data = [
            'id'   => $param['id'],
        ];
        $res = curl_request(getKkaudioApiUrl() . '/inner/blackList/delete', $data, 'urlencoded', 'GET');
        if(isset($res['code']) && $res['code']==0) {
            return 1;
        }else{
            return [
                'code' => 50000,
                'msg' => empty($res['msg']) ? '失败' : $res['msg'],
            ];
        }
    }

}
